package com.jsnkj.basic.adapter

import android.app.Activity
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.jsnkj.basic.R
import com.jsnkj.basic.bean.PopularizeInvitesEntity


class InvitingNewAdapter(
    val activity: Activity,
    private val itemList: List<PopularizeInvitesEntity.InvitesBean>
) :
    RecyclerView.Adapter<InvitingNewAdapter.HomeViewHolder>() {
    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): HomeViewHolder {
        val view: View =
            LayoutInflater.from(parent.context)
                .inflate(R.layout.rv_item_inviting_new, parent, false)
        return HomeViewHolder(view)
    }

    override fun onBindViewHolder(holder: HomeViewHolder, position: Int) {
        val item = itemList[position]
        holder.tvTime.text = item.date
        holder.tvDescription.text = item.remark
        holder.tvMoney.text = item.commission
        holder.tvMember.text = item.uuid
    }

    override fun getItemCount(): Int {
        return itemList.size
    }

    class HomeViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
        var tvTime: TextView
        var tvDescription: TextView
        var tvMoney: TextView
        var tvMember: TextView

        init {
            tvTime = itemView.findViewById<TextView>(R.id.tv_time)
            tvDescription = itemView.findViewById<TextView>(R.id.tv_description)
            tvMoney = itemView.findViewById<TextView>(R.id.tv_money)
            tvMember = itemView.findViewById<TextView>(R.id.tv_member)
        }
    }

}